Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

220
Vistas
Difference between import a module with and without ".js" in es6 module

I'm recently learning chrome extension development, and find out that: When I use

import { foo } from "./index"

in background.js, I will get an error: An unknown error occurred when fetching the script., while using

import { foo } from "./index.js"

Everything just works properly. Could someone please tell me the difference between these two ways?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

ES6 needs you to reference a file for it to fetch.

Extension-less or a directory to use index from are supported by external loaders such as webpack, with correct configurations.

With these, if you import without extension, it will look for an index.js inside your import path as if it were a folder.

Or If you have a folder foo, and inside it a file index.js, you can import ./foo without the extension and it will import the index file.

Directly in ES6 as far as I'm aware (e.g. for Chrome browser direct interpretation without some loader), I believe a full file path is necessary for local imports, so you should include the .js extension when you want to import a specific file.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda